package com.xuecheng.content.convert;

import com.xuecheng.api.content.model.dto.TeachplanDTO;
import com.xuecheng.api.content.model.vo.TeachplanVO;
import com.xuecheng.content.entity.Teachplan;
import com.xuecheng.content.entity.ex.TeachplanNode;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * Created on 2021/03/31/17:02 周三
 *
 * @author Lantin
 */
@Mapper
public interface TeachplanConvert {

    TeachplanConvert INSTANCE = Mappers.getMapper(TeachplanConvert.class);


    @Mappings({
            @Mapping(source = "childrenTreeNodes", target = "teachPlanTreeNodes"),
            @Mapping(source = "id", target = "teachPlanId")
    })
    TeachplanDTO teachplanNodeToDTO(TeachplanNode node);

    @Mappings({
            @Mapping(source = "id", target = "teachPlanId")
    })
    TeachplanDTO teachplanToDTO(Teachplan teachplan);


    @Mappings({
            @Mapping(source = "teachPlanId", target = "id")
    })
    Teachplan dtoToTeachPlan(TeachplanDTO teachplanDTO);

    TeachplanDTO voToTeachPlanDTO(TeachplanVO teachplanVO);

    List<TeachplanDTO> TeachplanNodeToDTOList(List<TeachplanNode> nodes);

}
